import { ChunkLib } from "../ChunkLib";
import ShaderLib from "../ShaderLib";

export default class TrailRepeatLineShader {
    public static getVertexShader() {
        return ShaderLib.getDefaultVertexShader();
    }
    public static getFragmentShader() {
        let shader = `
            varying vec2 uvTexcoord;
            uniform float time;
            uniform float linelength;
            uniform float mapwidth;
            uniform sampler2D map;
            uniform vec3 v_color;         
            void main(){  
              ${ChunkLib.precision_low}
                vec2 uv = uvTexcoord;
                vec4 fragColor = vec4(0.);
                float num = linelength/mapwidth;
                float dx = uv.x * num - time;
                fragColor = texture2D(map, vec2(fract(dx), uv.y));
                gl_FragColor = fragColor;
            }
        `;
        return shader;
    }
}
